package com.cheeven.cwliu.citation.steps;

import java.util.HashMap;
import org.w3c.dom.Document;

public class Step3 extends StepBase {

	public static void markRecords(HashMap<String, String> control) {
		logInfo("3. Select all references as Marked Record");
		
		String sid  = control.get("sid");
		String qid  = control.get("qid");
		String markFrom  = control.get("markFrom");
		String markTo  = control.get("markTo");
		
		logInfo(1, "sid={0}, qid={1}, markFrom={2}, markTo={3}", sid, qid, markFrom, markTo);		
		
		String markRecordsPage = httpPost(
				"https://apps.webofknowledge.com/MarkRecords.do"
				+ "?product=UA&mark_id=UDB&SID=" + sid
				+ "&qid=" + qid 
				+ "&search_mode=Refine",
				new String[][]{
					{"selectedIds", ""},
					{"colName", ""},
					{"mark_from", markFrom},
					{"mark_to", markTo},
					{"viewType", "summary"}
				});
		
		Document domdoc = toDOM(markRecordsPage);
		control.put("nextAction", "https://apps.webofknowledge.com/" + xpath("//a[contains(@href,'ViewMarkedList.do?action=Search')]/@href", domdoc));

		logInfo(1, "Marked List Page at {0}", control.get("nextAction"));
		
	}
}
